fix another link related memory issue with the gpx reader.
authortsteven4 <tsteven4@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 22 Aug 2013 12:45:45 +0000 (12:45 +0000)
committertsteven4 <tsteven4@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 22 Aug 2013 12:45:45 +0000 (12:45 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4552 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/gpx.cc

index e7b2a998b79931e7001ef94c0635c4d266f3467a..2421c0824671e18e058671f3ee223a9f9ee1890a 100644 (file)
@@ -57,8 +57,8 @@ static const char* input_fname;
 static gpsbabel::File* oqfile;
 static gpsbabel::XmlStreamWriter* writer;
 static short_handle mkshort_handle;
-static const char* link_url;
-static char* link_text = NULL;
+static const char* link_url = NULL;
+static const char* link_text = NULL;
 
 static const char* input_string = NULL;
 static int input_string_len = 0;
@@ -687,7 +687,7 @@ gpx_start(void* data, const XML_Char* xml_el, const XML_Char** xml_attr)
     break;
   case tt_wpt_link:
     if (attr[0] && attr[1] && 0 == strcmp(attr[0], "href")) {
-      link_url = attr[1];
+      link_url = xstrdup(attr[1]);
     }
     break;
   case tt_rte:
@@ -1205,6 +1205,10 @@ gpx_end(void* data, const XML_Char* xml_el)
       xfree(link_text);
       link_text = NULL;
     }
+    if (link_url) {
+      xfree(link_url);
+      link_url = NULL;
+    }
     break;
   case tt_wpt_link_text:
     if (cdatastrp[0]) {